import mixin from '../../../AddParkingLot/AddParkingLotComponents/rule/opt';
import specialRule from './specialRule';
import utils from '@/mixins/utils.js';
export default {
	mixins: [mixin, specialRule, utils],
	data() {
		return {};
	},
	methods: {
		back() {
			this.$router.push({
				name: 'allParkinglotInfo',
				query: this.$route.query
			});
		},

		testSpecialListRule() {
			return new Promise((resolve, reject) => {
				console.log(this.$refs['parkSpecialChargeVoList']);
				this.$refs['parkSpecialChargeVoList'].validate(valid => {
					if (valid) {
						resolve(true);
					} else {
						resolve(false);
					}
				});
			});
		},
		checkUnit(rule, value, callback) {
			const integer_reg = /^[1-9]\d*$/;
			if (value === '') {
				callback(new Error('时间不能为空'));
			} else if (!integer_reg.test(value)) {
				callback(new Error('必须是大于0的整数'));
			} else {
				callback();
			}
		},
		checkMoney(rule, value, callback) {
			if (value === '') {
				callback(new Error('金额不能为空'));
			} else {
				const v = Number(value);
				if (!(v >= 0)) {
					callback(new Error('必须大于等于0'));
				} else {
					callback();
				}
			}
		}
	}
};
